package com.example.rfidwms;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class recy_item_stockCount_Adapter extends RecyclerView.Adapter<recy_item_stockCount_Adapter.ViewHolder> {
    public List<Map<String,Object>> list=new ArrayList<>();

    public Context con;
    public LayoutInflater inflater;


    public recy_item_stockCount_Adapter(List<Map<String,Object>> list, Context con){
        this.con=con;
        this.list=list;
        inflater=LayoutInflater.from(con);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= inflater.inflate(R.layout.recyclerview_item_stockcount,null);
        ViewHolder viewHolder=new ViewHolder(view);
        return viewHolder;

    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, @SuppressLint("RecyclerView") int position) {

        holder.countbyepc.setText(list.get(position).get("countbyepc").toString());
        holder.unit.setText(list.get(position).get("unit").toString());
        holder.name.setText(list.get(position).get("name").toString());
        holder.classify_num.setText(list.get(position).get("classify_num").toString());
        holder.spec.setText(list.get(position).get("specs").toString());
//        holder.epc.setText(list.get(position).get("epc").toString());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        public TextView countbyepc;
        public TextView classify_num;
        public TextView name;
        public TextView spec;
        public TextView unit;
//        public TextView epc;

        public ViewHolder(View itemView) {
            super(itemView);
            countbyepc=(TextView) itemView.findViewById(R.id.recy_C_countbyepc);
            classify_num= (TextView) itemView.findViewById(R.id.recy_C_classify_num);
            name= (TextView) itemView.findViewById(R.id.recy_C_name);
            spec=(TextView) itemView.findViewById(R.id.recy_C_spec);
            unit = (TextView) itemView.findViewById(R.id.recy_C_unit);
//            epc = (TextView) itemView.findViewById(R.id.recy_C_epc);
        }
    }

}